//
// Created by hkkzzxz on 24-8-31.
//

#ifndef YUNSHI_LOGMANAGER_H
#define YUNSHI_LOGMANAGER_H

// 日志管理类
#include <spdlog/spdlog.h>
#include <spdlog/async.h>
#include <spdlog/sinks/basic_file_sink.h>
#include <spdlog/sinks/stdout_color_sinks.h>

#include "Singleton.h"

class LogManager : public Singleton<LogManager> {
    friend class Singleton<LogManager>;

public:
    // 初始化日志系统
    void init(const std::string &logFilePath = "Log/logs/app_log.txt",
              spdlog::level::level_enum level = spdlog::level::debug);

    // 获取控制台日志器
    std::shared_ptr<spdlog::logger> getConsoleLogger();

    // 获取文件日志器
    std::shared_ptr<spdlog::logger> getFileLogger();

    // 清理日志系统
    void shutdown();

private:
    LogManager() {}

    ~LogManager() {
        spdlog::shutdown();
    }

    // 异步日志器
    static LogManager *instance;
    static std::mutex instanceMutex;
    std::shared_ptr<spdlog::logger> consoleLogger;
    std::shared_ptr<spdlog::logger> fileLogger;
};


#endif //YUNSHI_LOGMANAGER_H
